refactor(changelog): simplify logic for get_oldest_and_newest_rev#1539
Merged
Lee-W merged 5 commits intocommitizen-tools:v4-9-0-testfrom Aug 30, 2025
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v4-9-0-test #1539 +/- ##
==============================================
Coverage ? 98.31%
==============================================
Files ? 58
Lines ? 2669
Branches ? 0
==============================================
Hits ? 2624
Misses ? 45
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bearomorphism
commented
Jun 12, 2025
0b7774c to
7316c2f
Compare
bearomorphism
commented
Jun 13, 2025
commitizen/changelog.py
Outdated
Comment on lines
285
to
291
| def get_next_tag_name_after_version(tags: Iterable[GitTag], version: str) -> str | None: | ||
| a, b = tee(chain((tag.name for tag in tags), [None])) | ||
| next(b, None) | ||
| try: | ||
| return next(y for x, y in zip(a, b) if x == version) | ||
| except StopIteration: | ||
| raise NoCommitsFoundError(f"Could not find a valid revision range. {version=}") |
Collaborator
Author
There was a problem hiding this comment.
Thanks @gbaian10 for reminding me here we don't have to use a while loop.
1d9f4ab to
277d8f9
Compare
Lee-W
reviewed
Aug 24, 2025
277d8f9 to
83f52ac
Compare
83f52ac to
b1d3821
Compare
Original "push" stage has been deprecated since pre-commit v3.2.0. See pre-commit/pre-commit#2732 and pre-commit/pre-commit#2808 for detailed information.
…rk unused for get_smart_tag_range
b1d3821 to
b8e19f8
Compare
Lee-W
approved these changes
Aug 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
get_oldest_and_newest_revget_smart_range, I believe we can replace it with a simpler function.get_next_tag_name_after_versionis based on an assumption that "all GitTags are unique". If the oldest tag's name is the inputversion, then it returnsNone. The behavior aligns with "ReturnNoneforoldest_revif the oldest tag is the last tag in the list and matches the requested oldest tag"Checklist
Code Changes
poetry alllocally to ensure this change passes linter check and tests